package com.sg.service.base.app.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sg.common.util.CommonFunctionHelper;
import com.sg.dto.base.app.req.*;
import com.sg.entity.OmsEvaObjTargetCycleOset;
import com.sg.service.base.app.MOmsEvaObjTargetCycleOsetService;
import com.wicket.okrapp.common.dto.FieldInfo;
import com.wicket.okrapp.common.exception.BizException;
import com.wicket.okrapp.dal.mapper.mbg.OmsEvaObjTargetCycleOsetMapper;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author ：
 * @version 1.0
 * @since 2022/1/19 15:39
 */
@Service
public class MOmsEvaObjTargetCycleOsetServiceImpl
        extends ServiceImpl<OmsEvaObjTargetCycleOsetMapper, OmsEvaObjTargetCycleOset>
        implements MOmsEvaObjTargetCycleOsetService {

    @Autowired
    OmsEvaObjTargetCycleOsetMapper omsEvaObjTargetCycleOsetMapper;

    /**
     * 3-3-09-01批量查OKR责任主体个人目标周期目标[2248]
     * gen by moon at 10/16/2022, 7:14:26 AM
     */
    @Trace(operationName = "3-3-09-01批量查OKR责任主体个人目标周期目标")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsEvaObjTargetCycleOset> batchQueryOkrPsEvaObjTargetCycleTarget(BatchQueryOkrPsEvaObjTargetCycleTargetReq reqDto) {

        try {
            QueryWrapper<OmsEvaObjTargetCycleOset> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            reqDto.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
            if (reqDto.getOkrPsEvaObjTargetCycleTargetList() == null || reqDto.getOkrPsEvaObjTargetCycleTargetList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("okr_ps_eva_obj_target_cycle_id", reqDto.getOkrPsEvaObjTargetCycleTargetList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsEvaObjTargetCycleOset.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsEvaObjTargetCycleOset.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsEvaObjTargetCycleOset.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsEvaObjTargetCycleOset>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-09-01批量查OKR责任主体部门目标周期目标[2250]
     * gen by moon at 10/16/2022, 7:14:27 AM
     */
    @Trace(operationName = "3-3-09-01批量查OKR责任主体部门目标周期目标")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsEvaObjTargetCycleOset> batchQueryOkrDptEvaObjTargetCycleTarget(BatchQueryOkrDptEvaObjTargetCycleTargetReq reqDto) {

        try {
            QueryWrapper<OmsEvaObjTargetCycleOset> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            reqDto.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
            if (reqDto.getOkrDptEvaObjTargetCycleTargetList() == null || reqDto.getOkrDptEvaObjTargetCycleTargetList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("okr_dpt_eva_obj_target_cycle_id", reqDto.getOkrDptEvaObjTargetCycleTargetList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsEvaObjTargetCycleOset.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsEvaObjTargetCycleOset.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsEvaObjTargetCycleOset.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsEvaObjTargetCycleOset>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-09-01批量查被评对象目标周期目标列表[2255]
     * gen by moon at 11/25/2022, 4:33:34 PM
     */
    @Trace(operationName = "3-3-09-01批量查被评对象目标周期目标列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsEvaObjTargetCycleOset> batchQueryEvaObjTargetCycleTarget(BatchQueryEvaObjTargetCycleTargetReq reqDto) {

        try {
            QueryWrapper<OmsEvaObjTargetCycleOset> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            reqDto.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
            if (reqDto.getEvaObjTargetCycleTargetList() == null || reqDto.getEvaObjTargetCycleTargetList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("eva_obj_target_cycle_id", reqDto.getEvaObjTargetCycleTargetList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsEvaObjTargetCycleOset.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsEvaObjTargetCycleOset.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsEvaObjTargetCycleOset.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsEvaObjTargetCycleOset>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-09-01批量查评价画像目标周期目标[2655]
     * gen by moon at 10/16/2022, 7:14:29 AM
     */
    @Trace(operationName = "3-3-09-01批量查评价画像目标周期目标")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsEvaObjTargetCycleOset> batchQueryEvaPortraitTargetCycleTarget(BatchQueryEvaPortraitTargetCycleTargetReq reqDto) {

        try {
            QueryWrapper<OmsEvaObjTargetCycleOset> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            reqDto.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
            if (reqDto.getEvaPortraitTargetCycleTargetList() == null || reqDto.getEvaPortraitTargetCycleTargetList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("eva_portrait_target_cycle_id", reqDto.getEvaPortraitTargetCycleTargetList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsEvaObjTargetCycleOset.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsEvaObjTargetCycleOset.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsEvaObjTargetCycleOset.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsEvaObjTargetCycleOset>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-09-01批量查目标任务书部门目标周期目标[2656]
     * gen by moon at 10/16/2022, 7:14:31 AM
     */
    @Trace(operationName = "3-3-09-01批量查目标任务书部门目标周期目标")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsEvaObjTargetCycleOset> batchQueryMLevelEvaObjTargetCycleTarget(BatchQueryMLevelEvaObjTargetCycleTargetReq reqDto) {

        try {
            QueryWrapper<OmsEvaObjTargetCycleOset> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            reqDto.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
            if (reqDto.getMLevelEvaObjTargetCycleTargetList() == null || reqDto.getMLevelEvaObjTargetCycleTargetList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("m_level_eva_obj_target_cycle_id", reqDto.getMLevelEvaObjTargetCycleTargetList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsEvaObjTargetCycleOset.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsEvaObjTargetCycleOset.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsEvaObjTargetCycleOset.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsEvaObjTargetCycleOset>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-09-01查被评对象目标周期目标[2657]
     * gen by moon at 3/30/2023, 12:39:04 PM
     */
    @Trace(operationName = "3-3-09-01查被评对象目标周期目标")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public OmsEvaObjTargetCycleOset queryEvaObjTargetCycleTargetDetail(QueryEvaObjTargetCycleTargetDetailReq reqDto) {

        try {
            reqDto.setIsValid("FALSE");
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            reqDto.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
            QueryWrapper<OmsEvaObjTargetCycleOset> queryWrapper = new QueryWrapper<>();
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, new ArrayList<>());
            queryWrapper.orderByDesc("create_time");
            List<OmsEvaObjTargetCycleOset> retList = super.list(queryWrapper);
            if (retList != null && retList.size() > 0) {
                OmsEvaObjTargetCycleOset retData = retList.get(0);

                return retData;
            }
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-09-01批量查被评对象目标周期目标By画像[2751]
     * gen by moon at 10/16/2022, 7:14:33 AM
     */
    @Trace(operationName = "3-3-09-01批量查被评对象目标周期目标By画像")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsEvaObjTargetCycleOset> batchQueryEvaObjTargetCycleTargetSetByEvaPortrait(BatchQueryEvaObjTargetCycleTargetSetByEvaPortraitReq reqDto) {

        try {
            QueryWrapper<OmsEvaObjTargetCycleOset> queryWrapper = new QueryWrapper<>();
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            reqDto.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
            if (reqDto.getEvaObjTargetCycleTargetList() == null || reqDto.getEvaObjTargetCycleTargetList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("eva_portrait_target_cycle_id", reqDto.getEvaObjTargetCycleTargetList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsEvaObjTargetCycleOset.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsEvaObjTargetCycleOset.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsEvaObjTargetCycleOset.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsEvaObjTargetCycleOset>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-09-01批量删被评对象目标周期目标[2752]
     * gen by moon at 9/13/2022, 12:34:11 AM
     */
    @Trace(operationName = "3-3-09-01批量删被评对象目标周期目标")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean batchDeleteEvaObjTargetCycleTarget(List<String> reqDto) {

        if (reqDto == null || reqDto.size() == 0) {
            return false;
        }

        return super.removeByIds(reqDto);
    }

    /**
     * 3-3-09-01批量改被评对象目标周期目标[2877]
     * gen by moon at 10/16/2022, 7:14:34 AM
     */
    @Trace(operationName = "3-3-09-01批量改被评对象目标周期目标")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean batchUpdateEvaObjTargetCycleTarget(List<OmsEvaObjTargetCycleOset> omsEvaObjTargetCycleOset) {

        if (omsEvaObjTargetCycleOset == null || omsEvaObjTargetCycleOset.size() == 0) {
            return false;
        }
        return super.saveOrUpdateBatch(omsEvaObjTargetCycleOset);

    }

    /**
     * 3-3-09-01查询被评对象目标周期目标列表[3458]
     * gen by moon at 10/16/2022, 7:14:35 AM
     */
    @Trace(operationName = "3-3-09-01查询被评对象目标周期目标列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsEvaObjTargetCycleOset> queryEvaObjTargetCycleTargetList(QueryEvaObjTargetCycleTargetListReq reqDto) {

        try {
            QueryWrapper<OmsEvaObjTargetCycleOset> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            reqDto.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID

            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsEvaObjTargetCycleOset.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsEvaObjTargetCycleOset.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsEvaObjTargetCycleOset.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsEvaObjTargetCycleOset>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-09-01修改被评对象目标周期目标[3460]
     * gen by moon at 10/16/2022, 7:14:36 AM
     */
    @Trace(operationName = "3-3-09-01修改被评对象目标周期目标")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateEvaObjTargetCycleTarget(OmsEvaObjTargetCycleOset omsEvaObjTargetCycleOset) {

        return super.updateById(omsEvaObjTargetCycleOset);
    }

    /**
     * 3-3-09-01批量增指标被评对象目标周期目标[3597]
     * gen by moon at 10/16/2022, 7:14:37 AM
     */
    @Trace(operationName = "3-3-09-01批量增指标被评对象目标周期目标")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean batchAddTargetObjEvaObjTargetCycleTarget(List<OmsEvaObjTargetCycleOset> omsEvaObjTargetCycleOset) {

        if (omsEvaObjTargetCycleOset == null || omsEvaObjTargetCycleOset.size() == 0) {
            return false;
        }

        return super.saveBatch(omsEvaObjTargetCycleOset.stream().map(item -> {
            item.setEvaObjOsetId(CommonFunctionHelper.getUid());//DISTRIBUTED_ID
            item.setBatchEndtTime(CommonFunctionHelper.getFutureTime());//FUTURE_CURRENT_TIME
            item.setIsUpdate("TRUE");
            item.setUpdateStatus("NEW");
            item.setArchivngType("NOT_ARCHIVE");
            item.setIsEditing("TRUE");
            item.setIsArchive("FALSE");
            item.setSubjectLifeCycle("EDITING");
            item.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
            item.setCreateInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
            item.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
            item.setCreateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
            item.setIsValid("FALSE");
            item.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            item.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
            return item;
        }).collect(Collectors.toList()));
    }

    /**
     * 3-3-09-01新增指标被评对象目标周期目标[3599]
     * gen by moon at 10/16/2022, 7:14:38 AM
     */
    @Trace(operationName = "3-3-09-01新增指标被评对象目标周期目标")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String addTargetObjEvaObjTargetCycleTarget(OmsEvaObjTargetCycleOset omsEvaObjTargetCycleOset) {
        omsEvaObjTargetCycleOset.setEvaObjOsetId(CommonFunctionHelper.getUid());//DISTRIBUTED_ID
        omsEvaObjTargetCycleOset.setBatchEndtTime(CommonFunctionHelper.getFutureTime());//FUTURE_CURRENT_TIME
        omsEvaObjTargetCycleOset.setIsUpdate("TRUE");
        omsEvaObjTargetCycleOset.setUpdateStatus("NEW");
        omsEvaObjTargetCycleOset.setArchivngType("NOT_ARCHIVE");
        omsEvaObjTargetCycleOset.setIsEditing("TRUE");
        omsEvaObjTargetCycleOset.setIsArchive("FALSE");
        omsEvaObjTargetCycleOset.setSubjectLifeCycle("EDITING");
        omsEvaObjTargetCycleOset.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        omsEvaObjTargetCycleOset.setCreateInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        omsEvaObjTargetCycleOset.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        omsEvaObjTargetCycleOset.setCreateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        omsEvaObjTargetCycleOset.setIsValid("FALSE");
        omsEvaObjTargetCycleOset.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
        omsEvaObjTargetCycleOset.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
        if (super.save(omsEvaObjTargetCycleOset)) {
            return omsEvaObjTargetCycleOset.getEvaObjOsetId();
        } else {
            return "-1";
        }

    }

    /**
     * M3更新目标周期目标对象树【循环开始】[4141]
     * gen by moon at 10/16/2022, 7:14:38 AM
     */
    @Trace(operationName = "M3更新目标周期目标对象树【循环开始】")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateTargetCycleValueObjTreeLoopStart(List<OmsEvaObjTargetCycleOset> omsEvaObjTargetCycleOset) {

        if (omsEvaObjTargetCycleOset == null || omsEvaObjTargetCycleOset.size() == 0) {
            return false;
        }
        return super.saveOrUpdateBatch(omsEvaObjTargetCycleOset);

    }

    /**
     * M-构造被评对象目标周期目标设置验证数据[4258]
     * gen by moon at 10/16/2022, 7:14:39 AM
     */
    @Trace(operationName = "M-构造被评对象目标周期目标设置验证数据")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String buildEvaObjTarCycTargetSet(OmsEvaObjTargetCycleOset omsEvaObjTargetCycleOset) {
        omsEvaObjTargetCycleOset.setEvaObjOsetId(CommonFunctionHelper.getUid());//DISTRIBUTED_ID
        omsEvaObjTargetCycleOset.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        omsEvaObjTargetCycleOset.setCreateInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        if (omsEvaObjTargetCycleOset != null && omsEvaObjTargetCycleOset.getSubjectLifeCycle() != null && omsEvaObjTargetCycleOset.getSubjectLifeCycle().equals("CURRENTLY_VALID")) {
            omsEvaObjTargetCycleOset.setReleaseInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//RELEASED_CURRENT_INDUCTIONID
        }
        if (omsEvaObjTargetCycleOset != null && omsEvaObjTargetCycleOset.getSubjectLifeCycle() != null && omsEvaObjTargetCycleOset.getSubjectLifeCycle().equals("ARCHIVING")) {
            omsEvaObjTargetCycleOset.setArchiveInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//ARCHIVE_CURRENT_INDUCTIONID
        }
        omsEvaObjTargetCycleOset.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        omsEvaObjTargetCycleOset.setCreateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        if (omsEvaObjTargetCycleOset != null && omsEvaObjTargetCycleOset.getSubjectLifeCycle() != null && omsEvaObjTargetCycleOset.getSubjectLifeCycle().equals("CURRENTLY_VALID")) {
            omsEvaObjTargetCycleOset.setReleaseTime(CommonFunctionHelper.getCurrentTime());//RELEASE_SYSTEM_CURRENT_TIME
        }
        if (omsEvaObjTargetCycleOset != null && omsEvaObjTargetCycleOset.getSubjectLifeCycle() != null && omsEvaObjTargetCycleOset.getSubjectLifeCycle().equals("ARCHIVING")) {
            omsEvaObjTargetCycleOset.setArchiveTime(CommonFunctionHelper.getCurrentTime());//HISTORICAL_ARCHIVING
        }
        omsEvaObjTargetCycleOset.setIsValid("FALSE");
        omsEvaObjTargetCycleOset.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
        omsEvaObjTargetCycleOset.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
        if (super.save(omsEvaObjTargetCycleOset)) {
            return omsEvaObjTargetCycleOset.getEvaObjOsetId();
        } else {
            return "-1";
        }

    }

    /**
     * M3-3-09-01一键删除被评对象目标周期目标设置验证数据[4424]
     * gen by moon at 10/16/2022, 7:14:40 AM
     */
    @Trace(operationName = "M3-3-09-01一键删除被评对象目标周期目标设置验证数据")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean autoDeleteEvaObjTarCycTargetSet(String evaObjOsetId) {

        return super.removeById(evaObjOsetId);
    }

    /**
     * M3-3-09-01查询被评对象目标周期目标设置详情[4465]
     * gen by moon at 3/30/2023, 12:39:05 PM
     */
    @Trace(operationName = "M3-3-09-01查询被评对象目标周期目标设置详情")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public OmsEvaObjTargetCycleOset queryEvaObjTarCycTargetSetDetail(QueryEvaObjTarCycTargetSetDetailReq reqDto) {

        try {

            QueryWrapper<OmsEvaObjTargetCycleOset> queryWrapper = new QueryWrapper<>();
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, new ArrayList<>());
            queryWrapper.orderByDesc("create_time");
            List<OmsEvaObjTargetCycleOset> retList = super.list(queryWrapper);
            if (retList != null && retList.size() > 0) {
                OmsEvaObjTargetCycleOset retData = retList.get(0);

                return retData;
            }
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-09-01批量删被评对象目标周期目标设置[2752]
     * gen by moon at 10/16/2022, 7:14:34 AM
     */
    @Trace(operationName = "3-3-09-01批量删被评对象目标周期目标设置")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean batchDeleteEvaObjTargetCycleOset(List<String> reqDto) {

        if (reqDto == null || reqDto.size() == 0) {
            return false;
        }

        return super.removeByIds(reqDto);
    }

    /**
     * 3-3-09-01批量增被评对象目标周期目标[4723]
     * gen by moon at 10/16/2022, 7:14:42 AM
     */
    @Trace(operationName = "3-3-09-01批量增被评对象目标周期目标")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean batchAddEvaObjTargetCycleTarget(List<OmsEvaObjTargetCycleOset> omsEvaObjTargetCycleOset) {

        if (omsEvaObjTargetCycleOset == null || omsEvaObjTargetCycleOset.size() == 0) {
            return false;
        }

        return super.saveBatch(omsEvaObjTargetCycleOset.stream().map(item -> {
            item.setEvaObjOsetId(CommonFunctionHelper.getUid());//DISTRIBUTED_ID
            item.setBatchEndtTime(CommonFunctionHelper.getFutureTime());//FUTURE_CURRENT_TIME
            item.setIsUpdate("TRUE");
            item.setUpdateStatus("NEW");
            item.setIsEditing("TRUE");
            item.setArchivngType("NOT_ARCHIVE");
            item.setIsArchive("FALSE");
            item.setSubjectLifeCycle("EDITING");
            item.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
            item.setCreateInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
            item.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
            item.setCreateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
            item.setIsValid("FALSE");
            item.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            item.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
            return item;
        }).collect(Collectors.toList()));
    }

    /**
     * 3-3-9-01删除被评对象目标周期目标[4811]
     * gen by moon at 10/16/2022, 7:14:43 AM
     */
    @Trace(operationName = "3-3-9-01删除被评对象目标周期目标")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteEvaObjTargetCycleTarget(String evaObjOsetId) {

        return super.removeById(evaObjOsetId);
    }

    /**
     * 3-3-09-01查询被评对象目标周期目标设置详情[4817]
     * gen by moon at 3/30/2023, 12:39:06 PM
     */
    @Trace(operationName = "3-3-09-01查询被评对象目标周期目标设置详情")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public OmsEvaObjTargetCycleOset queryEvaObjTargetCycleOsetDetail(QueryEvaObjTargetCycleOsetDetailReq reqDto) {

        try {
            reqDto.setIsValid("FALSE");
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            QueryWrapper<OmsEvaObjTargetCycleOset> queryWrapper = new QueryWrapper<>();
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, new ArrayList<>());
            queryWrapper.orderByDesc("create_time");
            List<OmsEvaObjTargetCycleOset> retList = super.list(queryWrapper);
            if (retList != null && retList.size() > 0) {
                OmsEvaObjTargetCycleOset retData = retList.get(0);

                return retData;
            }
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-09-01修改被评对象目标周期目标设置[4818]
     * gen by moon at 10/31/2022, 9:17:45 PM
     */
    @Trace(operationName = "3-3-09-01修改被评对象目标周期目标设置")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateEvaObjTargetCycleOset(OmsEvaObjTargetCycleOset omsEvaObjTargetCycleOset) {
        omsEvaObjTargetCycleOset.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        omsEvaObjTargetCycleOset.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        return super.updateById(omsEvaObjTargetCycleOset);
    }

    /**
     * 3-3-09-01批量查询被评对象目标周期目标设置[5146]
     * gen by moon at 11/6/2022, 6:18:58 PM
     */
    @Trace(operationName = "3-3-09-01批量查询被评对象目标周期目标设置")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsEvaObjTargetCycleOset> batchQueryEvaObjTargetCycleOset(BatchQueryEvaObjTargetCycleOsetReq reqDto) {

        try {
            QueryWrapper<OmsEvaObjTargetCycleOset> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            if (reqDto.getEvaObjTargetCycleOsetList() == null || reqDto.getEvaObjTargetCycleOsetList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("eva_obj_target_cycle_id", reqDto.getEvaObjTargetCycleOsetList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsEvaObjTargetCycleOset.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsEvaObjTargetCycleOset.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsEvaObjTargetCycleOset.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsEvaObjTargetCycleOset>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-09-01查询目标周期权重设置等列表[6252]
     * gen by moon at 4/8/2023, 12:06:43 AM
     */
    @Trace(operationName = "3-3-09-01查询目标周期权重设置等列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsEvaObjTargetCycleOset> queryTargetCycleWeightSetEtcList(QueryTargetCycleWeightSetEtcListReq reqDto) {
        return null; //todo ruizhe dong
    }

    /**
     * M3-3-09-01查询被评对象目标周期目标设置列表测试[6252]
     * gen by moon at 4/9/2023, 10:40:16 PM
     */
    @Trace(operationName = "M3-3-09-01查询被评对象目标周期目标设置列表测试")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsEvaObjTargetCycleOset> queryEvaObjTarCycTargetSetList(QueryEvaObjTarCycTargetSetListReq reqDto) {
        return null; //todo ruizhe dong
    }

    /**
     * 3-3-09-01批量查目标设置列表By设置Id[6780]
     * gen by moon at 5/16/2023, 6:41:14 PM
     */
    @Trace(operationName = "3-3-09-01批量查目标设置列表By设置Id")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsEvaObjTargetCycleOset> batchQueryEvaObjTargetCycleOsetListByIds(BatchQueryEvaObjTargetCycleOsetListByIdsReq reqDto) {

        try {
            QueryWrapper<OmsEvaObjTargetCycleOset> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            if (reqDto.getEvaObjTargetCycleOsetList() == null || reqDto.getEvaObjTargetCycleOsetList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("eva_obj_oset_id", reqDto.getEvaObjTargetCycleOsetList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsEvaObjTargetCycleOset.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsEvaObjTargetCycleOset.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsEvaObjTargetCycleOset.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsEvaObjTargetCycleOset>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-09-01批量改被评对象目标周期目标设置[7627]
     * gen by moon at 10/30/2023, 8:52:53 PM
     */
    @Trace(operationName = "3-3-09-01批量改被评对象目标周期目标设置")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean batchUpdateEvaObjTargetCycleOset(List<OmsEvaObjTargetCycleOset> omsEvaObjTargetCycleOset) {

        if (omsEvaObjTargetCycleOset == null || omsEvaObjTargetCycleOset.size() == 0) {
            return false;
        }
        return super.saveOrUpdateBatch(omsEvaObjTargetCycleOset);

    }

    /**
     * 3-3-09-01查询目标周期目标设置详情[9417]
     * gen by moon at 4/19/2024, 8:08:06 PM
     */
    @Trace(operationName = "3-3-09-01查询目标周期目标设置详情")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public OmsEvaObjTargetCycleOset queryTargetCycleOsetDetail(QueryTargetCycleOsetDetailReq reqDto) {

        try {

            QueryWrapper<OmsEvaObjTargetCycleOset> queryWrapper = new QueryWrapper<>();
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, new ArrayList<>());
            queryWrapper.orderByDesc("create_time");
            List<OmsEvaObjTargetCycleOset> retList = super.list(queryWrapper);
            if (retList != null && retList.size() > 0) {
                OmsEvaObjTargetCycleOset retData = retList.get(0);

                return retData;
            }
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

}

